const {fork} = require('child_process')

var childProcess = fork('fork-child.js');
var index=0
var intervalID = setInterval(()=>{
    index++
    childProcess.send("this is message from parent process")
    if(index==10){
        clearInterval(intervalID)
    }
},2000)

childProcess.on("message",(chunk)=>{
    console.log(chunk)
})